<?php

class Application_Form_AjoutMembreForm extends Zend_Form
{
  public function init()
  {
    $this->setName('ajoutmembre');

    $id = new Zend_Form_Element_Hidden('id');

    $formname = new Zend_Form_Element_Hidden('formname');
    $formname->setValue('ajout');
    $this->addElement($formname);

    $t = new Application_Model_UsersTable();
    $u = $t->fetchAll();
    $select = new Zend_Form_Element_Select('vendeur');
    foreach($u as $h)
      {
	if($h['mdp'] != '')
	  {
	    $select->addMultiOption($h['login'],$h['nom'].' '.$h['prenom'].' - Pwd : OUI');
	  }
	else
	  {
	    $select->addMultiOption($h['login'],$h['nom'].' '.$h['prenom'].' - Pwd : NON');
	  }
      }
    $select->setLabel('Nouveau vendeur :');
    $select->setAttrib('id','userBox')->setAttrib('size',7)->setDecorators(array('Errors','FormErrors','ViewHelper','Label'));

    $pwd = new Zend_Form_Element_Password('pwd');
    $pwd->setLabel('Mot de passe (au moins 6 caractères) : ')
      ->addFilter('StripTags')
      ->addFilter('StringTrim')
      // ->addValidator('StringLength', false, array(6))
      ->setDecorators(array('ViewHelper','FormErrors','Label','Errors'));

    $pwd_verif = new Zend_Form_Element_Password('pwd_verif');
    $pwd_verif->setLabel('Retapez le mot de passe : ')
      ->addFilter('StripTags')
      ->addFilter('StringTrim')        
      ->setDecorators(array('ViewHelper','FormErrors','Label','Errors'));
  
    $send = new Zend_Form_Element_Submit('send2');
    $send->setLabel('Ajouter')
      ->setDecorators(array('ViewHelper','FormErrors','Errors'));

    $this->addElement($id)
      ->addElement($formname)
      ->addElement($select)
      ->addELement($pwd)
      ->addElement($pwd_verif)
      ->addElement($send);
  }

}